package com.mygame;

import android.graphics.Canvas;

public class GameManager extends Thread{

	private GameView view;
	private boolean running;
	
	private boolean isDelete=false;
	
	public GameManager(GameView view)
	{
		this.view = view;
		running = false;
	}
	
	public void setRunning(boolean run)
	{
		running = run;
	}
	
	public void run()
	{
		while (running)
		{
			Canvas c = null;
			try
			{
				c = view.getHolder().lockCanvas();
				if (!isDelete) {
					synchronized(view.getHolder())
					{
						view.onDraw(c);
					}
				}
			} 
			catch(Exception e) { }
			finally
				{
					if (c != null)
						view.getHolder().unlockCanvasAndPost(c);
				}
		}
	}
	
	public void setStanding(boolean run) {
		isDelete=run;
	}
}
